from django.db import models


# Create your models here.
class koji_package(models.Model):
    package_id = models.IntegerField(primary_key=True)
    package_name = models.CharField(max_length=100)

    def __str__(self):
        return f'{self.package_id} - {self.package_name}'


class koji_build(models.Model):
    build_id = models.IntegerField(primary_key=True)

    package_id = models.IntegerField()
    package_name = models.CharField(max_length=100)

    name = models.CharField(max_length=100)
    version = models.CharField(max_length=100)
    release = models.CharField(max_length=100)
    nvr = models.CharField(max_length=100)

    owner_id = models.IntegerField()
    owner_name = models.CharField(max_length=100)

    # 0: building, 1: complete, 2: deleted, 3: failed, 4: canceled
    state = models.CharField(max_length=100)
    source = models.CharField(max_length=1024, null=True)

    task_id = models.IntegerField(null=True)

    completion_time = models.FloatField(null=True)
    creation_time = models.FloatField()
    start_time = models.FloatField()

    tag = models.CharField(max_length=50, null=True)

    def __str__(self):
        return self.nvr


class koji_tag(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=50)

    def __str__(self):
        return f'{str(self.id)} - {self.name}'
